package com.draemoncode.weixindb.util;

import java.math.BigDecimal;
import java.text.DecimalFormat;

/**
 * Created by Administrator on 2017/4/11.
 */
public class ValueUtil {

    public static String toString(Object value){
        if(value != null){
            return String.valueOf(value);
        }
        return null;
    }

    public static Integer toInteger(Object value){
        if(value != null){
            return Integer.valueOf(String.valueOf(value));
        }
        return null;
    }

    public static BigDecimal toBigDecimal(Object value){
        if(value != null){
            Double aDouble = Double.valueOf(String.valueOf(value));
            return new BigDecimal(aDouble);
        }
        return null;
    }

    public static String formatMoney(BigDecimal value){
        if(value != null){
            DecimalFormat myformat = new DecimalFormat("0");
            return myformat.format(value);
        }
        return null;
    }

}
